//
//  WYMediaDetailBasicMessageCell.m
//  CirclePush
//
//  Created by admin on 2018/5/19.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYMediaDetailBasicMessageCell.h"
#import "WYBascMessageCell.h"
#import "WYMapList.h"
@interface WYMediaDetailBasicMessageCell()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)NSMutableArray *nameArray;

@end

@implementation WYMediaDetailBasicMessageCell

-(NSMutableArray *)nameArray
{
    if (!_nameArray) {
        _nameArray = [[NSMutableArray alloc]init];
    }
    return _nameArray;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    [self setUpUI];
    // Initialization code
}
-(void)setDataArray:(NSArray *)dataArray
{
    _dataArray = dataArray;
    [self.nameArray removeAllObjects];
    for (WYMapList *list in dataArray) {
        if (list.name.length||list.attrName.length) {
            if (list.value.length||list.attributeValue.length) {
                [self.nameArray addObject:list];
            }
           
        }
    }
    [self.tableView reloadData];
}
-(void)setUpUI
{
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.tableView registerNib:[UINib nibWithNibName:@"WYBascMessageCell" bundle:nil] forCellReuseIdentifier:@"WYBascMessageCell"];
    self.tableView.bounces = NO;
    
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.nameArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WYBascMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WYBascMessageCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"WYBascMessageCell" owner:nil options:nil].firstObject;
    }
    WYMapList *list = self.nameArray[indexPath.row];
    if (list.attrName.length) {
        cell.nameLabel.text = list.attrName;
    }else{
        cell.nameLabel.text = list.name;
    }
    if (list.attributeValue.length) {
        cell.valueLabel.text = list.attributeValue;
    }else{
        cell.valueLabel.text = list.value;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
   
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 44;
}






- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
